
// 保存ajax进行post请求下载
function ajax_download(url, data, $) {
	var $iframe, iframe_doc, iframe_html;
	
	if (($iframe = $('#download_iframe')).length === 0) {
		$iframe = $("<iframe id='download_iframe' style='display: none' src='about:blank'></iframe>")
				.appendTo("body");
	}

	iframe_doc = $iframe[0].contentWindow || $iframe[0].contentDocument;
	if (iframe_doc.document) {
		iframe_doc = iframe_doc.document;
	}

	iframe_html = "<html><head></head><body><form method='POST' action='" + url + "'>"

	Object.keys(data).forEach(function(key) {
		iframe_html += "<input type='hidden' name='" + key + "' value='" + data[key] + "'>";

	});

	iframe_html += "</form></body></html>";

	iframe_doc.open();
	iframe_doc.write(iframe_html);
	$(iframe_doc).find('form').submit();
}

// 表格默认参数
var $$ = $$ || {};
$$.tbconfig = {
	elem: '#LAY-table',
	even: true,  //开启隔行背景	
	cellMinWidth : 95,
	//size: 'sm',  //小尺寸的表格
	height: 'full-120',  //容器高度
	method: 'post',
	page: true, 
	limits: [20, 50, 100, 200], 
	limit: 20,  //默认采用25
	loading: true, 
	autoSort: false
}

$$.ajax = function(cfg) {
	var me = this;	
	$.ajax({
        type: 'post',
        dataType: 'json',
        url: cfg.url,
        data: cfg.data || cfg.param || {},
        async: (typeof cfg.async=='undefined') ? true : cfg.async,
        success: cfg.success || cfg.callback,
        error: cfg.error
    });
}
